<?php

namespace App\Models\Plane\PlaneOrders\Repositories\Interfaces;


use App\Models\Orders\Orders;
use App\Models\Plane\PlaneOrders\PlaneOrder;
use App\Models\Trip\OrderPay\OrderPay;
use Illuminate\Support\Collection;

interface PlaneOrderRepositoryInterface
{
    public function lists(array $param, int $page_size): Collection;

    public function listAll(array $param): Collection;

    /**
     * 获取出票中的订单
     * @param array $condition
     * @return Collection
     */
    public function getTicketingOrders(array $condition = []): Collection;

    /**
     * 获取改签中的订单
     * @param array $condition
     * @return Collection
     */
    public function getChangingOrders(array $condition = []): Collection;

    /**
     * 获取退票中的订单
     * @param array $condition
     * @return Collection
     */
    public function getReturningOrders(array $condition = []): Collection;

    /**
     * 创建订单
     *
     * @param array $data
     *
     * @return PlaneOrder
     */
    public function createPlaneOrder(array $data): PlaneOrder;

    /**
     * 创建订单
     *
     * @param array $orders
     *
     * @return array
     */
    public function createPlaneOrders(array $orders): array;


    /**
     * 改签订单
     *
     * @param PlaneOrder $origin_order_info
     * @param array      $new_order_data
     *
     * @return PlaneOrder
     */
    public function changePlaneOrder(PlaneOrder $origin_order_info, array $new_order_data): PlaneOrder;


    public function getOrderInfo(string $order_sn): ?PlaneOrder;

    /**
     * 外部单号 查询关联的全部订单
     *
     * @param string $out_order_sn 订票时 向服务商发送的外部订单单号,比如中转订单 就是一个外部单号 对应两个订单
     *
     * @return Collection
     */
    public function getOrdersByOutOrderSn(string $out_order_sn): Collection;

    public function getOrderInfoByOrder(Orders $order): PlaneOrder;

    public function getOrderShowInfo(string $order_sn): array;

    public function getOrderShowInfoDatasByPlaneOrder(PlaneOrder $order): array;

    public function getOrderShowInfoDatasByOrderSn(string $order_sn): array;

    public function cancelOrder(PlaneOrder $order, bool $manual): bool;


    public function destroy(PlaneOrder $order): bool;

    public function orderPaid(PlaneOrder $order, OrderPay $orderPay);

    public function ticketed(PlaneOrder $order, array $data);


    /**
     * 更新订单状态
     * @param PlaneOrder      $current_order
     * @param array           $update_data
     * @param Collection|null $update_passengers
     * @return bool
     */
    public function updateOrderState(PlaneOrder $current_order, array $update_data, Collection $update_passengers = null): bool;

    /**
     * 更新订单
     * @param PlaneOrder $current_order
     * @param array      $update_data
     * @return bool
     */
    public function updateOrder(PlaneOrder $current_order, array $update_data): bool;

    public function updateProviderPayState(PlaneOrder $current_order, int $pay_state, string $desc): bool;

    public function lastOrder(string $user_id): ?PlaneOrder;

    public function findOneByPlaneData(array $data): ?PlaneOrder;

    public function checkSameTripPlaneData(array $data): Collection;

    public function saveOutOrderId(PlaneOrder $order, string $out_order_id, array $subOrders = []): bool;

    public function saveOrderPaySn(PlaneOrder $order, string $pay_sn): bool;

    public function getChangeOriginOrderNeedRefund(PlaneOrder $order): array;

    public function getTripOrders(PlaneOrder $order): Collection;

    public function getTripSecondOrder(PlaneOrder $first_order): ?PlaneOrder;

    public function ticketFailedAndRefund(PlaneOrder $order, $passengers = null);

    public function passengerApplyRefund(PlaneOrder $order, $passengers);

    public function getOtherChangedOrders(PlaneOrder $order, bool $to_show): Collection;

    public function getOneOrdersByOutOrderSn(string $out_order_sn): PlaneOrder;

    public function getOneOrdersByOutOrderId(string $out_order_id): PlaneOrder;

    /**
     * 回填改签待结算的机票价格
     * @return mixed
     */
    public function refillChangingConfirmPrice(PlaneOrder $order, array $data): PlaneOrder;

}